getScaledMinimumFlingVelocity
Minimum absolute value of velocity to initiate a fling for a motion generated by an InputDevice with an id of inputDeviceId
, from an input source
and on a given motion event axis
.
Before utilizing this method to get a minimum fling velocity for a motion generated by the input device, scale the velocity of the motion events generated by the input device to pixels per second.
For instance, if you tracked AXIS_SCROLL vertical velocities generated from a SOURCE_ROTARY_ENCODER, the velocity returned from VelocityTracker will be in the units with which the axis values were reported in the motion event. Before comparing that velocity against the minimum fling velocity specified here, make sure that the AXIS_SCROLL velocity from the tracker is calculated in "units per second" (see computeCurrentVelocity, computeCurrentVelocity to adjust your velocity computations to "per second"), and use getScaledVerticalScrollFactor to change this velocity value to "pixels/second".
If the provided inputDeviceId
is not valid, or if the input device whose ID is provided does not support the given motion event source and/or axis, this method will return Integer.MAX_VALUE
.
Obtaining the correct arguments for this method call
inputDeviceId: if calling this method in response to a MotionEvent, use the device ID that is reported by the event, which can be obtained using getDeviceId. Otherwise, use a valid ID that is obtained from getId, or from an InputManager instance (getInputDeviceIds gives all the valid input device IDs).
axis: a MotionEvent may report data for multiple axes, and each axis may have multiple data points for different pointers. Use the axis for which you obtained the velocity for (VelocityTracker lets you calculate velocities for a specific axis. Use the axis for which you calculated velocity). You can use getMotionRanges to get all the InputDevice.MotionRanges for the InputDevice, from which you can derive all the valid axes for the device.
source: use getSource if calling this method in response to a MotionEvent. Otherwise, use a valid source for the InputDevice. You can use getMotionRanges to get all the InputDevice.MotionRanges for the InputDevice, from which you can derive all the valid sources for the device.
This method optimizes calls over multiple input device IDs, so caching the return value of the method is not necessary if you are handling multiple input devices.
Return
the minimum velocity, in pixels/second, to trigger fling.
Parameters
the Context associated with the view.
the ViewConfiguration to derive the minimum fling velocity from.
the ID of the InputDevice that generated the motion triggering fling.
the axis on which the motion triggering the fling happened. This axis should be a valid axis that can be reported by the provided input device from the provided input device source.
the input source of the motion causing fling. This source should be a valid source for the InputDevice whose ID is inputDeviceId
.